#include "teamboss_config.h"
#include "string_common.h"

const CTeamBossLv* CTeamBossCfg::Getbossinfo(int32_t level)const
{
	auto it = teamboss_config_.find(level);
	if ( it == teamboss_config_.end() )
	{
		return NULL;
	}
	return &(it->second);
}

const CTeamBossLv* CTeamBossCfg::GetDefaultInfo() const
{
	auto it = teamboss_config_.begin();
	if ( it  != teamboss_config_.end())
	{
		return &(it->second);
	}
	return NULL;
}

void CTeamBossCfg::LoadFromJson(const Json::Value& teamboss)
{
	Json::Value::Members _tmp = teamboss.getMemberNames();
	for (uint32_t i = 0; i < _tmp.size(); ++i)
	{
		std::string index = _tmp[i];
		CTeamBossLv bosslv;
		bosslv.LoadFromJson(teamboss[index]);

		teamboss_config_.insert(std::make_pair(bosslv.level(), bosslv));
	}
}

void CTeamBossLv::LoadFromJson(const Json::Value& bossinfo)
{
	level_ = bossinfo["level"].asInt();
	monsterid_ = bossinfo["monsterID"].asInt();
	award_kill_.LoadFromJson(bossinfo["award_kill"]);
}
